city_list = {
    "北京": {
        "东城区":{"东直门","王府井","崇文门"},
        "西城区":{"西直门","宣武门","动物园"},
        "海淀区":{"五道口","中关村","西苑"}
    },
    "河北": {
        "石家庄":{"新华区","裕华区","长安区"},
        "邢台":{"桥西区","桥东区","高开区"},
        "保定":{"竞秀区","莲池区","清苑区"}
    },
    "山东": {
        "济南":{"历下区","槐荫区","天桥区"},
        "青岛":{"市南区","市北区","城阳区"},
        "威海":{"环翠区","文登区","荣成市"}
    }
}
while True:
    for key in city_list:
        print(key)
    province_input = input("请选择省份,q键退出：")
    if province_input == "q":
        exit()
    elif province_input in city_list.keys():
        while True:
            for key1 in city_list.get(province_input):
                print(key1)
            city_input = input("请选择城市，b健返回上一层，q健退出：")
            if city_input == "b":
                break
            elif city_input == "q":
                exit()
            elif city_input in city_list[province_input]:
                while True:
                    for key2 in city_list[province_input][city_input]:
                        print(key2)
                    zui_input = input("b健返回，任意键退出")
                    if zui_input == "b":
                        break
                    elif zui_input in city_list[province_input][city_input]:
                        pass
                    else:
                        exit()
            else:
                print("输入错误，请重新输入")
    else:
        print("输入错误，请重新输入")


# layer = city_list
# layer_no = []
#
# while True:
#     for k in layer:
#         print(k)
#     user_input = input(">>>:").strip()
#     if user_input == 0:continue
#     if user_input in layer:
#         layer_no.append(layer)
#         layer = layer[user_input]
#     elif user_input == "b":
#         if len(layer_no) > 0:
#             layer = layer_no.pop()
#     elif user_input == "q":
#         exit("bay")
#     else:
#         print("输入错误，请重新输入")
